package net.ycxinxing.mcpebox;
import android.support.design.widget.Snackbar;
import android.view.View;
import java.lang.reflect.Method;
import android.widget.Toast;
import android.view.Gravity;
import net.ycxinxing.mcpebox.widget.mMessageToast;
import net.ycxinxing.mcpebox.mcpe.Level;
import net.ycxinxing.mcpebox.mcpe.MinecraftClient;
import net.ycxinxing.mcpebox.mcpe.Player;

public class NativeCallBack
{
	public static void setLevel(final Level level,final boolean jr, final boolean yc)
	{
		level.currentLevel=level;
		mApp.getmcActivity().runOnUiThread(new Runnable(){
				@Override
				public void run()
				{
					if(jr==false)
					{
						level.currentLevel=null;
					}
					mMessageToast.MakeText(mApp.getmcActivity(),(jr?"进入"+(yc?"远程":"本地"):"退出")+"世界",false).show();
					// TODO: Implement this method
				}});
	}
	public static boolean onClientGeneration(final String data,final String name)
	{
		final mObject r=new mObject(true);
		final mObject zt=new mObject(false);
		mApp.getmcActivity().runOnUiThread(new Runnable(){
				@Override
				public void run()
				{
					mDialog dlg=new mDialog(mApp.getmcActivity()){

						@Override
						public void onButtonClick(int i)
						{
							switch(i)
							{
								case 1:
									r.setData(false);
									break;
								case 2:
									r.setData(true);
									break;
							}
							zt.setData(true);
							// TODO: Implement this method
						}
					};
					dlg.setTitle("有人试图进入您的服务器");
					dlg.setMsg("ip:"+data+"\n端口:"+19132+"\n玩家名:"+name);
					dlg.setButton3("同意");
					dlg.setButton2("拒绝");
					dlg.setCanClose(false);
					dlg.show();
					// TODO: Implement this method
				}});
		while(!(boolean)zt.getData())
		{
			try
			{
				Thread.sleep(50);
			}
			catch (InterruptedException e)
			{}
		}
		return (boolean)r.getData();
	}
	public static void oninitClient(MinecraftClient client)
	{
		MinecraftClient.currentClient=client;
	}
	public static void onStartGame()
	{
		try{
			mApp.WaitForStartingGame.dismiss();
		}catch(Exception e){
			
		}
	}
	public static void onLocalPlayerLoad(Player player)
	{
		MinecraftClient.currentClient.displayClientMessage("<mcpebox>本地玩家进入");
	}
	public static native void registerClasses(Class level,Class player,Class client);
}
